﻿@model Apps.Models.WMS.WMS_Inv_AdjustModel
@using Apps.Web.Core;
@using Apps.Common;
@using Apps.Models.WMS;
@using Apps.Web;
@using Apps.Locale;
@using Apps.Models.Sys;
@{
    ViewBag.Title = "创建";
    Layout = "~/Views/Shared/_Index_LayoutEdit.cshtml";
    List<permModel> perm = null;
}

<script type="text/javascript">
$(function () {
    @*$('#Lot').combogrid({
        panelWidth: 300,
        panelHeight: 150,
        idField: 'LotDisp',
        textField: 'LotDisp',
        url: '@Url.Action("GetLotsByPart", "Inv")',
        method: 'post',
        editable: false,
        onSelect: onSelect,
        columns: [[
            { field: 'Lot', title: '批次号', width: 50, hidden: true },
            {
                field: 'LotDisp', title: '批次号', width: 50
            },
            {field:'Qty',title:'现有量',width:50},
            { field: 'StockQty', title: '备料数', width: 80, sortable: true, align: 'right' },
            { field: 'AvailableQty', title: '可用数量', width: 80, sortable: true, align: 'right' }
        ]],
        fitColumns: true
    });*@

    $("#btnSave").click(function () {
        if ($("form").valid()) {
            $.ajax({
                url: "@Url.Action("Create")",
                type: "Post",
                data: $("form").serialize(),
                dataType: "json",
                success: function (data) {
                    if (data.type == 1) {
                        window.parent.frameReturnByMes(data.message);
                        window.parent.frameReturnByReload(true);
                        window.parent.frameReturnByClose()
                    }
                    else {
                        window.parent.frameReturnByMes(data.message);
                    }
                }
            });
        }
        return false;
    });
    $("#btnReturn").click(function () {
         window.parent.frameReturnByClose();
    });
});

    function onSelect(index, row)
    {
        $("#Qty").html(row.AvailableQty);
    }

    function LoadLot()
    {
        var invId = $("#InvId").val();
        var subInvId = "";
        var partId = $("#PartId").val();
        $("#Lot").combogrid('grid').datagrid("load", { partId: partId, invId: invId });
    };

    function frameReturnByClose()
    {
        $("#modalwindow").window('close');
    }
    function frameReturnByMes(mes) {
        $.messageBox5s(Lang.Tip, mes);
    }
</script>
<div id="modalwindow" class="easyui-window" style="width:800px; height:400px;" data-options="modal:true,closed:true,minimizable:false,shadow:false"></div>
<div class="mvctool bgb">
@Html.ToolButton("btnSave", "fa fa-save", Resource.Save,ref perm, "Save", true)
@Html.ToolButton("btnReturn", "fa fa-reply", Resource.Reply,false)
</div>
@using (Html.BeginForm())
{
             @Html.HiddenFor(model => model.Id, new { @Value = 0})
             <input id="CreateTime" type="hidden" name="CreateTime" value="2000-1-1" />
 <table class="formtable">
     <tbody>
         <tr>
             <th>
                 @*@Html.LabelFor(model => model.InvAdjustBillNum)：*@
                 单据号：
             </th>
             <td>
                 @Model.InvAdjustBillNum（自动生成）
             </td>
             <td>@Html.ValidationMessageFor(model => model.InvAdjustBillNum)</td>
         </tr>
         <tr>
             <th>
                 @Html.LabelFor(model => model.PartId)：
             </th>
             <td>
                 <div style="height:0;width:0;overflow:hidden">
                     @Html.EditorFor(model => model.PartId)
                 </div>
                 <input id="PartList" name="PartList" readonly="readonly" type="text" style="width: 180px; display: inline; background: #dedede; ">
                 <a class="fa fa-plus-square color-gray fa-lg" href="javascript:showSelPart()"></a>
                 <script type="text/javascript">
                     function showSelPart()
                     {
                         $("#modalwindow").html("<iframe width='100%' height='100%' scrolling='no' frameborder='0'' src='/WMS/Part/PartLookUp'></iframe>");
                         $("#modalwindow").window({ title: '选择物料', width: SetGridWidthSub(20), height: SetGridHeightSub(45), iconCls: 'fa fa-plus' }).window('open');
                     }

                     function SetSelResultForPart(result, resultName)
                     {
                         $("#PartId").val(result);
                         $("#PartList").val(resultName);
                         //LoadLot();
                     }
                 </script>
             </td>
             <td>@Html.ValidationMessageFor(model => model.PartId)</td>
         </tr>
         <tr>
             <th>
                 @Html.LabelFor(model => model.InvId)：
             </th>
             <td>
                 @Html.DropDownListFor(model => model.InvId, ViewBag.Inv as SelectList)
                 @*@Html.DropDownListFor(model => model.InvId, ViewBag.Inv as SelectList, new { @onchange = "LoadLot()" })*@
             </td>
             <td>@Html.ValidationMessageFor(model => model.InvId)</td>
         </tr>
         @*<tr>
            <th>
                @Html.LabelFor(model => model.SubInvId)：
            </th>
            <td>
                @Html.EditorFor(model => model.SubInvId)
            </td>
            <td>@Html.ValidationMessageFor(model => model.SubInvId)</td>
        </tr>*@
         <tr>
             <th>
                 批次号(必输)：
             </th>
             <td>
                 @*<input id="Lot" name="Lot" value="">
                 <label id="Qty" for="Lot" name="Qty"></label>*@
                 @Html.EditorFor(model => model.Lot)
             </td>
             <td>@Html.ValidationMessageFor(model => model.Lot)</td>
         </tr>
         <tr>
             <th>
                 @Html.LabelFor(model => model.AdjustQty)：
             </th>
             <td>
                 @Html.EditorFor(model => model.AdjustQty)
             </td>
             <td>@Html.ValidationMessageFor(model => model.AdjustQty)</td>
         </tr>
         <tr>
             <th>
                 @Html.LabelFor(model => model.AdjustType)：
             </th>
             <td>
                 @*@Html.EditorFor(model => model.AdjustType)*@
                 @Html.DropDownListFor(model => model.AdjustType, Apps.BLL.Sys.SysParamBLL.GetSysParamByType((String)ViewBag.Type == "0" ? "ReturnGoodsType" : "AdjustType"))
             </td>
             <td>@Html.ValidationMessageFor(model => model.AdjustType)</td>
         </tr>
         <tr>
             <th>
                 @Html.LabelFor(model => model.Remark)：
             </th>
             <td>
                 @Html.EditorFor(model => model.Remark)
             </td>
             <td>@Html.ValidationMessageFor(model => model.Remark)</td>
         </tr>
         @*<tr>
            <th>
                @Html.LabelFor(model => model.Attr1)：
            </th>
            <td>
                @Html.EditorFor(model => model.Attr1)
            </td>
            <td>@Html.ValidationMessageFor(model => model.Attr1)</td>
        </tr>
        <tr>
            <th>
                @Html.LabelFor(model => model.Attr2)：
            </th>
            <td>
                @Html.EditorFor(model => model.Attr2)
            </td>
            <td>@Html.ValidationMessageFor(model => model.Attr2)</td>
        </tr>
        <tr>
            <th>
                @Html.LabelFor(model => model.Attr3)：
            </th>
            <td>
                @Html.EditorFor(model => model.Attr3)
            </td>
            <td>@Html.ValidationMessageFor(model => model.Attr3)</td>
        </tr>
        <tr>
            <th>
                @Html.LabelFor(model => model.Attr4)：
            </th>
            <td>
                @Html.EditorFor(model => model.Attr4)
            </td>
            <td>@Html.ValidationMessageFor(model => model.Attr4)</td>
        </tr>
        <tr>
            <th>
                @Html.LabelFor(model => model.Attr5)：
            </th>
            <td>
                @Html.EditorFor(model => model.Attr5)
            </td>
            <td>@Html.ValidationMessageFor(model => model.Attr5)</td>
        </tr>
        <tr>
            <th>
                @Html.LabelFor(model => model.CreatePerson)：
            </th>
            <td>
                @Html.EditorFor(model => model.CreatePerson)
            </td>
            <td>@Html.ValidationMessageFor(model => model.CreatePerson)</td>
        </tr>
        <tr>
            <th>
                @Html.LabelFor(model => model.ModifyPerson)：
            </th>
            <td>
                @Html.EditorFor(model => model.ModifyPerson)
            </td>
            <td>@Html.ValidationMessageFor(model => model.ModifyPerson)</td>
        </tr>
        <tr>
            <th>
                @Html.LabelFor(model => model.ModifyTime)：
            </th>
            <td >
               @Html.TextBoxFor(model => model.ModifyTime, new { @onClick = "WdatePicker()",@style = "width: 105px" })
            </td>
            <td>@Html.ValidationMessageFor(model => model.ModifyTime)</td>
        </tr>*@
     </tbody>
</table>
}

